﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;

namespace BiessesXmlReader
{
   public class CutList
    {
       public List<Part> Parts { get;private  set; }
       public Solution CutPattern { get;private set; }
       public Board Board { get;private set; }
       public Material Material { get;private set; }
       public string order { get;private set; }
       public int NParts { get;private set; }
       public int NBoards { get;private set; }

       public CutList()
       {
           this.Parts = new List<Part>();
       }
       public static CutList GetCutList(string xmlFile)
       {
           CutList c = new CutList();
           XElement x = XElement.Load(xmlFile);
           c.order = (x.Attribute("order") == null) ? string.Empty : x.Attribute("order").Value;
           c.NParts = (x.Attribute("NParts") == null) ? 0 :int.Parse( x.Attribute("NParts").Value);
           c.NBoards = (x.Attribute("NBoards") == null) ? 0 : int.Parse(x.Attribute("NBoards").Value);
           c.Parts = Part.GetParts(x);
           c.Material = Material.GetMaterial(x);
           c.Board = Board.GetBoard(x);
           c.CutPattern = Solution.GetSolution(x);
           return c;
       }

    }
}
